RAND
Section: MINTLIB LIBRARY FUNCTIONS
(3)
Updated: 3 March 1993
Index
Return to Main Contents
NAME
rand, srand - simple random number generator
SYNOPSIS
#include <stdlib.h>
int rand(void);
void srand(unsigned int seed);
DESCRIPTION
rand is a simple random number generator that returns pseudo-
random numbers in the range 0 to 2^15 - 1 (16-bit integers)
or 0 to 2^31 - 1 (32-bit integers). The period of this
random number generator is 2^31 - 2, irrespective of the
integer size.
srand can be called at any time to reset the random number
generator to a random starting point. The generator is
initially seeded with a value of 1.
SEE ALSO
random(3),
srandom(3)
NOTES
Although random is slower, it is a far better random
number generator.
It seems that BSD UN*X srand returns the previous seed.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- SEE ALSO
-
- NOTES
-
This document was created by
man2html,
using the manual pages.
Time: 11:15:02 GMT, June 22, 2025